import {
  getData,
  postData,
  putData,
  deleteData,
} from "@/api/common/index";

const baseUserMembershipInfo = "/api/user-membership-info";

const UserMembershipInfoUrl = {
  page: "/page",
  url: "",
  exportInfo: '/export',
  membership: '/membership'
};

export function getUserMembershipInfoPage(params: any, pageNo: number | null | undefined, pageSize: number | null | undefined): Promise<any> {
  let url = baseUserMembershipInfo + UserMembershipInfoUrl.page + "?pageNum=" + (pageNo ? pageNo : 1) + "&pageSize=" + (pageSize ? pageSize : 10);
  return postData(url, params);
}

export function getUserMembershipInfoDetail(id: number): Promise<any> {
  return getData(baseUserMembershipInfo + UserMembershipInfoUrl.url + "?id=" + id);
}

export function deleteUserMembershipInfo(ids: string): Promise<any> {
  return deleteData(baseUserMembershipInfo + UserMembershipInfoUrl.url + "?ids=" + ids);
}

export function addOrEditUserMembershipInfo(
  method: string,
  params: any
): Promise<any> {
  if ("put" == method) {
    return putData(baseUserMembershipInfo + UserMembershipInfoUrl.url, params);
  } else {
    return postData(baseUserMembershipInfo + UserMembershipInfoUrl.url, params);
  }
}

export function exportUserMembership(params: any, response: any): Promise<any> {
  let url = baseUserMembershipInfo + UserMembershipInfoUrl.exportInfo;
  return postData(url, params, response);
}

// 办理会员
export function addUserMembership(params: any): Promise<any> {
  return postData(baseUserMembershipInfo + UserMembershipInfoUrl.membership, params);
}
